<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>15.6.DOM-操作元素-样式属性操作-练习1</title>
    <style>
        body {
            box-sizing: border-box;
        }

        .box {
            position: relative;
            width: 100px;
            height: 110px;
            border: 1px solid #ccc;
            text-align: center;
            margin: 0 auto;
            color: orangered;
        }

        .box p {
            margin: 0;
            padding: 0;
            font-size: 14px;
            color: orangered;
        }

        .box img {
            display: block;
            width: 80px;
            margin: 0 auto;
            margin-top: 3px;
        }

        .btn_close {
            position: absolute;
            top: -1px;
            left: -17px;
            width: 15px;
            height: 15px;
            border: 1px solid #ccc;
            line-height: 12px;
            color: #ccc;
            cursor: pointer;
            font-style: normal;
        }
    </style>
</head>
<!-- 仿淘宝关闭二维码案例 -->
<!-- 核心思路：利用样式的显示与隐藏完成，display:none隐藏元素 display:block显示元素 -->
<!-- 点击按钮，就让这个二维码盒子隐藏起来即可 -->

<body>
    <div class="box">
        手机淘宝
        <img src="images/tao.png" alt="">
        <i class="btn_close">x</i>
    </div>
    <script>
        var btn = document.querySelector('.btn_close');
        var box = document.querySelector('.box');
        btn.onclick = function () {
            box.style.display = 'none';
        }
    </script>
</body>

</html>